-
-
Notifications
You must be signed in to change notification settings - Fork 233
Weak SDEPINN solver #1012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Weak SDEPINN solver #1012
Conversation
|
Messy PR aside, the CI needs work... |
|
src/NN_SDE_weaksolve.jl
Outdated
| (p̂(u0[i], t₀) .- Distributions.pdf(distrib[i], u0[i]) ~ P(0) for i in 1:length(u0)) | ||
| end | ||
|
|
||
| # # inside optimization loss |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this all for? It seems like it would be difficult for this to ever sample?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was actually testing with different forms of loss, this approach did sample well for GBM but not for OU.
src/NN_SDE_weaksolve.jl
Outdated
| # # I_ic = solve(IntegralProblem(f_ic, x_0, x_end, θ), norm_loss_alg, | ||
| # # HCubatureJL(), | ||
| # # reltol = 1e-8, abstol = 1e-8, maxiters = 10)[1] | ||
| # # return abs(I_ic) # I_ic loss AUC = 0? | ||
| # return sum(abs2, ftest_icloss(phi, θ)) # I_ic pointwise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am yet to clear this part (was tidying up some other parts of the code first). But here i was manually taking the quadrature of the diff between the expected & IC pdf.
| # absorbing Bcs | ||
| if absorbing_bc | ||
| @info "absorbing BCS used" | ||
|
|
||
| bcs = vcat(bcs, [p̂(x_0, T) ~ P(0), | ||
| p̂(x_end, T) ~ P(0)]...) | ||
| end | ||
|
|
||
| # reflecting Bcs | ||
| if reflective_bc | ||
| @info "reflecting BCS used" | ||
|
|
||
| bcs = vcat(bcs, [J(x_0, T) ~ P(0), | ||
| J(x_end, T) ~ P(0) | ||
| ]...) | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's infinite domain though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im not sure how we can enforce that properly? (so i though we could just enforcing on the user chosen truncated domain)
|
Make the commented dead code into instead options that can be switched in the algorithm, or delete them if they are never useful. |
Clear TODO left:
Weak
SDEPINNSolverThe current implementation of
SDEPINNis a Physics-Informed Neural Network (PINN) solver for scalar SDEs, solving Fokker–Planck (Kolmogorov forward) PDEs instead of sampling individual trajectories.1. Problem
We consider a 1D Itô SDE:
with scalar state$(X_t \in \mathbb{R})$ , general drift (f) and diffusion (g), and initial condition $(X_{t_0} = x_0)$ .
The solver learns the probability density (p(x,t)) satisfying the Fokker–Planck PDE:
2. Domain and boundary conditions
Spatial domain:$(x \in [x_0, x_\text{end}])$ - The user must decide this based on rough range of expected SDE solution.
Initial condition approximated as a narrow PDF:
Boundary conditions:
Absorbing:
$p(x_0, t) = p(x_{end}, t) = 0 $
Reflecting (zero flux at chosen spatial domain's boundaries) :
$J(x,t) = f(x,t)p(x,t) - \frac{1}{2} \frac{\partial}{\partial x}\big[g(x,t)^2 p(x,t)\big] = 0$
Currently (for below results) only reflective BCs were enabled - in practice, one can choose the consistent BC loss terms.
3. Loss formulation
The total loss consists of :
The total loss minimized during training:
Currently, IC loss is implemented pointwise; normalization enforces integrated probability mass.
4. Potential improvements
X.TL;DR
SDEPINNsolves scalar SDEs at the density level via PINNs, enforcing PDE, BCs, ICs, and normalization.Current results :
LogNormalDistribution)Normaldistribution)Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
Add any other context about the problem here.